const origin = 'http://59.36.87.106:9080';

module.exports = {
  publicPath: '/header',
  devServer: {
    port: 6601,
    proxy: {
      // 跨域代理
      '/code': {
        target: origin + '/iot_user',
        ws: true,
        logLevel: 'debug',
        changeOrigin: true
      },
      // 搜索
      '/search': {
        target: origin + '/iot_common',
        ws: true,
        changeOrigin: true
      },
      // 消息
      '/message': {
        target: origin + '/iot_common',
        ws: true,
        changeOrigin: true
      },
      // 验证码
      '/login': {
        target: origin + '/iot_login',
        ws: true,
        changeOrigin: true,
        pathRewrite: {
          '^/login': ''
        }
      },
      // 个人信息
      '/user': {
        target: origin + '/iot_user',
        ws: true,
        changeOrigin: true
      }
    }
  },
  productionSourceMap: false,
  configureWebpack: config => {
    if (process.env.NODE_ENV === 'production') {
      // 清空console
      config.optimization.minimizer[0].options.terserOptions.compress.warnings = false;
      config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true;
      config.optimization.minimizer[0].options.terserOptions.compress.drop_debugger = true;
      config.optimization.minimizer[0].options.terserOptions.compress.pure_funcs = ['console.log'];
    }
  }
};
